﻿
using System;
using System.Collections.Generic;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace FXnaEngine.Graphics
{


   public  class FMesh
    {

          #region Member Fields
        protected VertexBuffer vb;
        protected IndexBuffer ib;
        protected PrimitiveType type;
        protected VertexDeclaration decl;
        protected int numVertices;
        protected int numPrimitives;


       //附加的属性,需要否？以及是否需要vertex,indics的原始数据，动态构建可能都需要呢

        BoundingSphere boundingSphere;



        #endregion

        #region Constructors
        /// <summary>
        /// Creates a mesh defined using XNA's geometry primitives
        /// </summary>
        public FMesh()
        {
            type = PrimitiveType.TriangleList;
        }
        #endregion

        #region Properties
        /// <summary>
        /// Gets or sets the VertexBuffer
        /// </summary>
        public VertexBuffer VertexBuffer
        {
            get { return vb; }
            set { vb = value; }
        }

        /// <summary>
        /// Gets or sets the IndexBuffer 
        /// </summary>
        public IndexBuffer IndexBuffer
        {
            get { return ib; }
            set { ib = value; }
        }

        /// <summary>
        /// Gets or sets primitive type used to render this mesh. 
        /// Default is PrimitiveType.TriangleList
        /// </summary>
        public PrimitiveType PrimitiveType
        {
            get { return type; }
            set { type = value; }
        }

        /// <summary>
        /// Gets or sets the vertex declaration
        /// </summary>
        public VertexDeclaration VertexDeclaration
        {
            get { return decl; }
            set { decl = value; }
        }

        /// <summary>
        /// Gets or sets the number of vertices set in VertexBuffer
        /// </summary>
        public int NumberOfVertices
        {
            get { return numVertices; }
            set { numVertices = value; }
        }

        /// <summary>
        /// Gets or sets the number of primitive shapes defined with PrimitiveType
        /// </summary>
        public int NumberOfPrimitives
        {
            get { return numPrimitives; }
            set { numPrimitives = value; }
        }
        #endregion

        #region IDisposable Members

        public void Dispose()
        {
            if (vb != null)
                vb.Dispose();

            if (ib != null)
                ib.Dispose();
        }

        #endregion


    }
}
